function [ result ]=calcHammingLoss( Y, Y_hat )
%Computing the hamming loss
%Pre_Labels: the predicted labels of the classifier, if the ith instance belong to the jth class, Pre_Labels(j,i)=1, otherwise Pre_Labels(j,i)=-1
%test_target: the actual labels of the test instances, if the ith instance belong to the jth class, test_target(j,i)=1, otherwise test_target(j,i)=-1

test_target = Y';
Pre_Labels = Y_hat';

[num_class,num_instance]=size(Pre_Labels);
miss_pairs=sum(sum(Pre_Labels~=test_target));

HammingLoss=miss_pairs/(num_class*num_instance);
result = -HammingLoss;

end
